﻿#include "mysql_tool.h"

MysqlTool::MysqlTool() {
    initDatabase();

    if (isSuccessOpenDatabase()) {
        query = QSqlQuery(database);
    }
}


MysqlTool::~MysqlTool() {

}

void MysqlTool::initDatabase() {
    database = QSqlDatabase::addDatabase("QODBC");
    database.setHostName("127.0.0.1");
    database.setPort(3306);
    database.setUserName("root");
    database.setPassword("123123");
    database.setDatabaseName("mysql_address_book_001");
}

bool MysqlTool::isSuccessOpenDatabase() {
    return database.open();
}

